package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * 平台后台 - 会员支付策略配置
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-10
 */
@Entity
@Table(schema = "public", name = "ord_platform_payment", indexes = {@Index(name = "ord_platform_payment_name_idx", columnList = "name"), @Index(name = "ord_platform_payment_all_members_idx", columnList = "allMembers"), @Index(name = "ord_platform_payment_status_idx", columnList = "status")})
public class PlatformPaymentDO implements Serializable {
    private static final long serialVersionUID = 4780493164740738856L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_platform_payment_seq")
    @SequenceGenerator(sequenceName = "ord_platform_payment_seq", name = "ord_platform_payment_seq", allocationSize = 1)
    private Long id;

    /**
     * 新增、修改时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime createTime;

    /**
     * 支付策略名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String name;

    /**
     * 是否适用所有会员
     */
    @Column
    private Boolean allMembers;

    /**
     * 状态，0-停用，1-启用
     */
    @Column
    private Integer status;

    /**
     * 一对多双向关联支付方式设置
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "payment", cascade = {CascadeType.DETACH, CascadeType.REMOVE}, fetch = FetchType.LAZY)
    private Set<PlatformPaymentTypeDO> payTypes;

    /**
     * 一对多双向关联适用会员
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "payment", cascade = {CascadeType.DETACH, CascadeType.REMOVE}, fetch = FetchType.LAZY)
    private Set<PlatformPaymentMemberDO> members;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getAllMembers() {
        return allMembers;
    }

    public void setAllMembers(Boolean allMembers) {
        this.allMembers = allMembers;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Set<PlatformPaymentTypeDO> getPayTypes() {
        return payTypes;
    }

    public void setPayTypes(Set<PlatformPaymentTypeDO> payTypes) {
        this.payTypes = payTypes;
    }

    public Set<PlatformPaymentMemberDO> getMembers() {
        return members;
    }

    public void setMembers(Set<PlatformPaymentMemberDO> members) {
        this.members = members;
    }
}
